<?php
	session_start();
	require("../inc/functions.php");
	if(!isEmployee())
		header("Location: ../index.php");
	require_once("../inc/models/orders_model.php");
	if(isset($_POST['submit'])){
		$row = $_POST;
		EditOrder($row);
		header("Location: index.php");
	}
	else{
		$results = GetOrder($_REQUEST['id']);
		$customers = GetCustomers();
	}
?>

<!DOCTYPE html>
<html lang="en">
	<?php include('../inc/head.php'); ?>
	<body>
	<?php include('../inc/navigation.php'); ?>
			<div class="span9">
				<div class="row-fluid">
					<h2>I.D.: <?=$results['id'] ?></h2>
					
										<form class="well" method="post" action="#">
						<div class="control-group">
			            	<label class="control-label" for="customer_id">Customers I.D.:</label>
			             <div class="controls">
			                <select name="customer_id" id="customer_id">
			                	<?php while($rs = $customers->fetch_assoc()): ?>
			             			<option value="<?=$rs['id'] ?>"><?=$rs['first_name']?> <?=$rs['last_name']?></option>
			             			<?php endwhile; ?>
			                	</select>
			               </div>
			            </div>
			            <div class="control-group">
			            	<label class="control-label" for="amount">Amount:</label>
			             <div class="controls">
			                <input type="text" name="amount" id="amount" value="<?=$results['amount'] ?>" />
			               </div>
			            </div>
			            <div class="control-group">
			            	<label class="control-label" for="shipping_name">Shipping Name:</label>
			             <div class="controls">
			                <input type="text" name="shipping_name" id="shipping_name" value="<?=$results['shipping_name'] ?>"/>
			               </div>
			            </div>
			            <div class="control-group">
			            	<label class="control-label" for="address">Address:</label>
			             <div class="controls">
			                <input type="text" name="address" id="address" value="<?=$results['address'] ?>" />
			               </div>
			            </div>
			            <div class="control-group">
			            	<label class="control-label" for="city">City:</label>
			             <div class="controls">
			                <input type="text" name="city" id="city" value="<?=$results['city'] ?>" />
			               </div>
			            </div>
			            <div class="control-group">
			            	<label class="control-label" for="state">State:</label>
			             <div class="controls">
			                <input type="text" name="state" id="state" value="<?=$results['state'] ?>" />
			               </div>
			            </div>
			            <div class="control-group">
			            	<label class="control-label" for="zip">Zip:</label>
			             <div class="controls">
			                <input type="text" name="zip" id="zip" value="<?=$results['zip'] ?>" />
			               </div>
			            </div>
			            <div class="control-group">
			            	<label class="control-label" for="country">Country:</label>
			             <div class="controls">
			                <input type="text" name="country" id="country" value="<?=$results['country'] ?>" />
			               </div>
			            </div>
			            <div class="control-group">
			            	<label class="control-label" for="phone">Phone:</label>
			             <div class="controls">
			                <input type="text" name="phone" id="phone" value="<?=$results['phone'] ?>" />
			               </div>
			            </div>
			            <div class="control-group">
			            	<label class="control-label" for="tax">Tax:</label>
			             <div class="controls">
			                <input type="text" name="tax" id="tax" value="<?=$results['tax'] ?>" />
			               </div>
			            </div>
			            <div class="control-group">
			            	<label class="control-label" for="email">Email:</label>
			             <div class="controls">
			                <input type="text" name="email" id="email" value="<?=$results['email'] ?>" />
			               </div>
			            </div>			            
			            <div class="control-group">
			            	<label class="control-label" for="date">Date:</label>
			             <div class="controls">
			                <input type="text" name="date" id="date" value="<?=$results['date'] ?>" />
			               </div>
			            </div>		
			            <div class="control-group">
			            	<label class="control-label" for="shipped">Shipped:</label>
			             <div class="controls">
			                <input type="text" name="shipped" id="shipped" value="<?=$results['shipped'] ?>" />
			               </div>
			            </div>		
			            <div class="control-group">
			            	<label class="control-label" for="tracking_number">Tracking Number:</label>
			             <div class="controls">
			                <input type="text" name="tracking_number" id="tracking_number" value="<?=$results['tracking_number'] ?>" />
			               </div>
			            </div>	
			            <div class="control-group">
			            	<label class="control-label" for="date">Date:</label>
			             <div class="controls">
			                <input type="text" name="date" id="date" value="<?=$results['date'] ?>" />
			               </div>
			            </div>			
			            <input type="hidden" name="id" id="id" value="<?=$results['id'] ?>" />
						<input type="submit" name="submit" value="Submit" />
					</form>
				</div>
			</div>
		</div>
	</div>
	
	<!-- All Bootstrap JavaScript Files -->
	<script src="../inc/bootstrap/js/jquery.js"></script>
    <script src="../inc/bootstrap/js/bootstrap.js"></script>
	
	</body>
</html>
